#include <iostream>
class A {
public:
    A(int x_ = 99){
        this->x = x_;
        std::cout << "default copy\n";
    };
    A(const A &a)  //拷贝构造函数
    {
        this->x = a.x;
        std::cout << "copy 构造\n";
    }
    A& operator=(const A &a) // 拷贝赋值
    {
        
        this->x = a.x;
        std::cout << "copy assignment\n";
        return *this;
    }
    int x;

};

int main()
{
    A a; //default copy
    a.x = 20; 
    A a2(a); //copy 构造
    a = a2; //copy assignment , 没有新对象被调用，不会调用拷贝构造，只会调用拷贝赋值
    std::cout << a.x << std::endl;

    A a3 = a2; //调用拷贝构造函数，有新对象被调用，只会调用拷贝构造
    std::cout << a3.x << std::endl;
    return 0;
}